<!--
 * @Author: xjt
 * @Date: 2021-06-25 11:26:32
 * @LastEditTime: 2021-06-26 17:15:28
 * @Description: 隔离点房间查看
 * @LastEditors: cqg
-->
<template>
  <div class="basic-from" v-dialogDrag>
    <el-dialog custom-class="small-padding-dialog" :close-on-click-modal="false" title="查看" :visible.sync="dialogVisible" width="90%" @close="handleClosed">
      <el-tabs v-model="activeName" @tab-click="handleClick">
        <el-tab-pane label="隔离点房间信息" name="隔离点房间信息">
          <el-form :model="formData" ref="dialogForm" class="form-wrap" style="padding-top:0px;">
            <el-form-item label="隔离点名称" prop="hotelName">
              {{
              formData.hotelName
              }}
            </el-form-item>
            <el-form-item label="房间所属楼层" prop="roomFloor">
              {{
              formData.roomFloor
              }}
            </el-form-item>
            <el-form-item label="房间号" prop="roomNum">
              {{
              formData.roomNum
              }}
            </el-form-item>
            <el-form-item label="使用类型" prop="useType">
              {{
              formData.useType | dict("use_type")
              }}
            </el-form-item>
            <el-form-item label="房间状态" prop="roomState">
              {{
              formData.roomState | dict("room_state")
              }}
            </el-form-item>
            <el-form-item label="使用开始时间" prop="useStartTime">
              {{
              formData.useStartTime
              }}
            </el-form-item>
            <el-form-item label="使用终止时间" prop="useEndTime">
              {{
              formData.useEndTime
              }}
            </el-form-item>
            <el-form-item label="备注" class="full" prop="remark">
              <p>{{ formData.remark }}</p>
            </el-form-item>
          </el-form>
        </el-tab-pane>
        <el-tab-pane label="房间使用记录" name="房间使用记录">
          <div class="basic-form">
            <dataList :pageInfo="pager" searchName="keyword" pure>
              <el-table ref="multipleTable" :data="tableData" border>
                <el-table-column type="index" width="50" label="序号"></el-table-column>
                <el-table-column prop="name" label="姓名" width="100"></el-table-column>
                <el-table-column prop="cardId" label="证件号码"></el-table-column>
                <el-table-column prop="gender" label="性别" :formatter="dictFormate"></el-table-column>
                <el-table-column prop="telPhone" label="联系方式"></el-table-column>
                <el-table-column prop="movePersonType" label="入住人员类型" :formatter="dictFormate"></el-table-column>
                <el-table-column prop="dataSource" label="隔离人员来源" :formatter="dictFormate"></el-table-column>
                <el-table-column prop="moveStartTime" label="入住开始时间"></el-table-column>
                <el-table-column prop="moveEndTime" label="入住终止时间"></el-table-column>
                <el-table-column prop="moveDay" label="入住天数"></el-table-column>
                <el-table-column prop="remark" label="备注" show-overflow-tooltip></el-table-column>
              </el-table>
            </dataList>
          </div>
        </el-tab-pane>
      </el-tabs>
    </el-dialog>
  </div>
</template>

<script>
import { getObj, pageMoveHouseRecord } from "@/views/yq-hotel/api/room.js";
export default {
  name: "preview",
  provide () {
    return {
      //初始化数据
      initList: this.queryData,
    };
  },
  data () {
    return {
      tableData: [],
      activeName: "隔离点房间信息",
      //弹窗开关
      dialogVisible: false,
      // 表单项
      formData: {
        name: "",
        cardId: "",
        gender: "",
        telPhone: "",
        movePersonType: "",
        dataSource: "",
        moveStartTime: "",
        moveEndTime: "",
        moveDay: "",
        remark: "",
      },
      // 请求参数
      params: {
        current: 1,
        size: 20,
        keyword: "",
      },
      // 分页
      pager: {
        total: 0, // 总页数
        current: 1, // 当前页数
        size: 20, // 每页显示多少条
      },
    };
  },
  methods: {
    async handleClick (tab, event) {
      tab.name == "房间使用记录" && this.queryData()
    },
    //字典翻译，
    dictFormate (row, column, cellValue) {
      //物业类型
      let dict;
      switch (column.property) {
        case 'gender':
          dict = this.getDict('gender').find(p => p.value == cellValue)
          break;
        case 'movePersonType':
          dict = this.getDict('move_person_type').find(p => p.value == cellValue)
          break;
        case 'dataSource':
          dict = this.getDict('data_source').find(p => p.value == cellValue)
          break;
      }
      if (dict) {
        return dict.label
      }
      return ''
    },
    async queryData () {
      let requestData = { ...this.params, houseId: this.formData.houseId };
      let res = await pageMoveHouseRecord(requestData);
      const { current, size, total, records } = res.data.data;
      this.tableData = records;
      this.params = requestData;
      this.pager = { total, current, size };
    },
    //开启弹窗
    async show (data = {}) {
      let rps = await getObj(data.houseId);
      this.formData = { ...this.formData, ...rps.data.data };
      this.dialogVisible = true;
    },
    // 弹窗关闭还原
    handleClosed () {
      let _formData = JSON.parse(JSON.stringify(this.formData));
      for (let i in _formData) {
        _formData[i] = "";
      }
      this.activeName = "隔离点房间信息",
        this.formData = _formData;
      this.$refs.dialogForm.resetFields();
    },
  },
};
</script>

<style lang="scss" scoped>
.addDialog {
  /deep/ .el-date-editor--datetime {
    width: 100%;
  }
  .album {
    .el-col {
      margin-bottom: 20px;
    }
    .img {
      width: 100%;
      height: 200px;
    }
  }
}
.stagnationPoint {
  @include formWrap(4);
}
</style>
